home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / clipper / ks94an.zip / ISENVVAR.HDR < prev    next >
Text File  |  1994-04-25  |  2KB  |  79 lines

  1. /******************************************************************************
  2.                  The Klipper Library, for CA-Clipper 5.x
  3.         Copyright (c), 1994, Wallace Information Systems Engineering
  4.  
  5. FUNCTION:
  6.  
  7. _IsEnvVar( acVarNames, lContent ) --> xElement
  8.  
  9. PARAMETERS:
  10.  
  11. acVarNames : Array of strings to use as DOS Environment var names
  12. lContent   : TRUE  = Return CONTENTS of found variable (DEFAULT)
  13.              FALSE = Return NUMBER of array element found
  14.  
  15. SHORT:
  16.  
  17. Tests existence of, and optionally returns, contents of DOS env variables.
  18.  
  19. DESCRIPTION:
  20.  
  21. _IsEnvVar() scans the environment looking for any of the environment
  22. variables listed in acVarNames.
  23.  
  24. As soon as one is found:
  25.  
  26. If lContent is TRUE, the contents of the variable are returned as a
  27. string.  Else, the element number of the found variable is returned.
  28.  
  29.  
  30.  
  31. If none of the variable names in acVarNames[] matches a DOS Environment:
  32.  
  33. If lContent is TRUE, the return value is empty (""). Else, the return value
  34. is 0.
  35.  
  36. The variable name elements are case insensitive.  The search stops at the
  37. FIRST match.
  38.  
  39. NOTE:
  40.  
  41.  
  42.  
  43. EXAMPLE:
  44.  
  45. Scenario:
  46.  
  47.     DOS Environment variables "U_NAME=KIRBY_WALLACE" and
  48.     "LOGIN_NAME="KIRBYW".  None of the others exist.
  49.  
  50. #define CONTENT .T.
  51. #define ELEMENT .F.
  52.  
  53. acVars = {  "USERID"     ,
  54.             "USERNAME"   ,
  55.             "USER_NAME"  ,
  56.             "U_NAME"     ,
  57.             "USER_ID"    ,
  58.             "LOGIN_NAME"   }
  59.  
  60. t = _IsEnvVar( acVars, CONTENT )
  61. Result: t = "KIRBY_WALLACE"
  62.  
  63.  
  64. t = _IsEnvVar(acVars, ELEMENT )
  65. Result: t = 4
  66.  
  67.  
  68. In this example, I have asked the function to look for any of the DOS
  69. environment variables in acVars.  In this case, U_NAME *and* LOGIN_NAME
  70. exist.  Since U_NAME is referenced first, the function will return either the
  71. contents or the element number of U_NAME.
  72.  
  73. Basically, this is a function that get information from a list of *possible*
  74. DOS env. vars.  It is used, for example, in _FScreen() to put the user name
  75. on the screen if it is defined in any of a number of popular user name
  76. variables that are likely to exist at run-time.
  77.  
  78. ******************************************************************************/
  79.